package com.lz.controller;

import javax.annotation.Resource;

import com.lz.entity.User;
import com.lz.service.UserService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 测试保存数据方法.
     * @return
     */
    @RequestMapping("/save")
    public String save(){
        User d = new User();
        d.setName("Angel");
        userService.save(d);//保存数据.
        return"save";
    }

    @RequestMapping("/update/{id}")
    public String update(@PathVariable final Long id){
        User user=userService.update(id);
        return user.toString();
    }
}
